package com.shoppingmall.widget;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.shoppingmall.R;

import razerdp.basepopup.BasePopupWindow;

/**
 * 2020/3/14
 * 描述：底部弹窗
 */
public class BottomSelectPhotosPopwin extends BasePopupWindow {

    private TextView openAlbumTv, openCameraTv, cancelTv;
    private OnSureClickListener onSureClickListener;

    public BottomSelectPhotosPopwin(Context context) {
        super(context);
        setPopupGravity(Gravity.BOTTOM);
        setOutSideTouchable(false);

        openAlbumTv = findViewById(R.id.tv_open_album);
        openCameraTv = findViewById(R.id.tv_open_camera);
        openAlbumTv = findViewById(R.id.tv_cancel);
    }

    @Override
    public View onCreateContentView() {
        return createPopupById(R.layout.popwin_select_photos);
    }

    private void initEvent() {
        cancelTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });

        openAlbumTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onSureClickListener.openAlbum();
            }
        });

        openCameraTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onSureClickListener.openCamera();
            }
        });
    }


    public void setOnSureClickListener(OnSureClickListener onSureClickListener) {
        this.onSureClickListener = onSureClickListener;
    }

    public interface OnSureClickListener {

        void openAlbum();

        void openCamera();

    }
}
